﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FastReport;
using MINERP.DAL.Statistics;

namespace MINERP.Statistics.Forms
{
    public partial class FrmProductCount : Form
    {
        public FrmProductCount()
        {
            InitializeComponent();
        }
        private static FrmProductCount instance = null;
        public static FrmProductCount GetInstance
        {
            get
            {
                if (instance == null)
                {
                    instance = new FrmProductCount();

                }
                return instance;
            }
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {

                this.Cursor = Cursors.WaitCursor;
                DataSet set = ProductStatDAL.GetProductCount(Convert.ToDateTime(dateTimePickerStart.Text),
                                                                 Convert.ToDateTime(dateTimePickerEnd.Text
                                                                     ));
                set.WriteXml(@"C:\windows\xmlData\产品信息.xml", XmlWriteMode.WriteSchema);
                Report report = new Report();
                report.Load(Application.StartupPath + "\\Report\\产品信息.frx");
                report.Preview = previewControl1;
                report.SetParameterValue("ParaStartTime", dateTimePickerStart.Text);
                report.SetParameterValue("ParaEndTime", dateTimePickerEnd.Text);
                previewControl1.Refresh();
                previewControl1.Show();
                report.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("读取数据失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

        }

        private void FrmProductCount_Load(object sender, EventArgs e)
        {

        }

        private void FrmProductCount_FormClosing(object sender, FormClosingEventArgs e)
        {
            instance = null;
        }
    }
}
